from .order_book import OrderBook
from typing import Dict
from .stock_order import StockOrder
from enum import Enum

class ExchangeStatus(Enum):
    IDLE = 0  # 交易所空闲
    PRE_OPEN_CALL_AUCTIONING = 1  # 早盘集合竞价期间
    PRE_OPEN_AUCTION = 2     # 早盘集合竞价
    CONTINUOUS_AUCTION = 3      # 连续竞价
    PRE_CLOSE_CALL_AUCTIONING = 4     # 收盘集合竞价期间
    PRE_CLOSE_AUCTION = 5     # 收盘集合竞价
    CLOSED = 6    # 交易所关闭
    

class Exchange:
    def __init__(self):
        self.__orderbooks: Dict[str, OrderBook] = {}
        self.__status: ExchangeStatus = ExchangeStatus.IDLE  # 初始状态为交易所空闲

    # 获取当前交易所状态
    def get_status(self) -> ExchangeStatus:
        return self.__status
    
    # 设置交易所状态
    def set_status(self, status: ExchangeStatus) -> None:
        if not isinstance(status, ExchangeStatus):
            raise ValueError("Invalid exchange status")
        self.__status = status

    # 下单
    def place_order(self, order: StockOrder):
        return